﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/*
存储从TXT文件读取并封装到的info对象
 */
public class DataLists : MonoBehaviour {

	public static DataLists instance;
	public List<WeaponInfo> weaponInfos = new List<WeaponInfo>();
    private static bool flag = false;//防止回到场景再创建一个GameManager


	void Awake()
	{
		instance = this;
	}

    void Start()
    {
        //设置GameManager转换场景时不被销毁
        if (!flag)
        {
            DontDestroyOnLoad(gameObject);
            flag = true;
        }
    }

	// 默认等级为1
	public WeaponInfo FindWeaponInfoById(int id){
		return FindWeaponInfoByIdAndGrade(id, "D");
	}


	// 根据武器Id和武器等级得到武器
	public WeaponInfo FindWeaponInfoByIdAndGrade(int id, string grade){
		foreach (WeaponInfo info in weaponInfos)
		{
			if (info.ID == id)
			{
				SetWeaponGrade(info.TypeId, grade);
				return info;
			}
		}
		return null;
	}

	


	// 设置武器等级而改变属性
	public void SetWeaponGrade(int typeId, string grade)
	{

	}


}
